<div id="content">
    <div id="page-heading">
        <h1>Survey management<?php echo $this->Html->link("Add Survey", array('controller' => $lN, 'action' => 'add', 'admin' => true),array('class'=>'button')); ?></h1>
    </div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <?php echo $this->Html->image('../images/shared/side_shadowleft.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
            </th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized">
                <?php echo $this->Html->image('../images/shared/side_shadowright.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
            </th>
	</tr>
	<tr>
            <td id="tbl-border-left"></td>
            <td>
                <div id="content-table-inner">
                    <div id="table-content">
                        <?php 
                            echo $this->Session->flash();
                        ?>
                        <table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
                            <tr>
                                <th class="table-header-repeat line-left">
                                   Title
                                </th>
                                <th class="table-header-repeat line-left">
                                   Description
                                </th>
                                <th class="table-header-repeat line-left">
                                   Point earned
                                </th>
                                <th class="table-header-repeat line-left">
                                   Survey Type
                                </th>
                                <th class="table-header-repeat line-left">
                                   Created
                                </th>
                                <th class="table-header-repeat line-left">
                                   Created By
                                </th>
                                <th class="table-header-repeat line-left">
                                   Question
                                </th>
                                <th class="table-header-repeat line-left">
                                   Status
                                </th>
                                <th class="table-header-repeat line-left"><a href="">Options</a></th>
                            </tr>
                        <?php 
                            $alt = 0;
                            foreach($values as $value): 
                                $alt_row = $alt % 2;
                                $alt_rows = ($alt_row == 1)? 'alternate-row': '';
                                $response = Response::count_response($value[$sN]['id']);
                        ?>
                            <tr class="<?php echo $alt_rows; ?>">
                                <td>
                                    <?php echo $value[$sN]['title']; ?>
                                </td>
                                <td>
                                    <?php echo $value[$sN]['description']; ?>
                                </td>
                                <td>
                                    <?php echo $value[$sN]['point_earned']; ?>
                                </td>
                                <td>
                                    <?php echo Survey::get_type($value[$sN]['type']); ?>
                                </td>
                                <td>
                                    <?php echo $value[$sN]['created']; ?>
                                </td>
                                <td>
                                    <?php echo User::get_username($value[$sN]['created_by']); ?>
                                </td>
                                <td>
                                    <?php echo $this->Html->link(SurveyQuestion::count_question_by_survey($value[$sN]['id']),array('controller' => 'surveys', 'action' => 'questions', $value[$sN]['id']), array('title' => "Question list", "class" => "info-tooltip")) ?>
                                </td>
                                <td>
                                    <?php 
                                    if(($value[$sN]['status']==1)){
                                        echo "Active".$this->Html->link('Make it Inactive',array('action'=>'block',$value[$sN]['id']),array('class'=>'button'));
                                    }else{
                                        echo 'Inactive'.$this->Html->link('Make it public',array('action'=>'public',$value[$sN]['id']),array('class'=>'button'));
                                    }
                                    ?>
                                </td>
                                <td class="options-width">
                                    <?php 
                                        echo $this->Html->link(' ', array('controller' => 'surveys', 'action' => 'edit', $value[$sN]['id']), array('title' => "Edit", "class" => "icon-5 info-tooltip"));
                                    ?>
                                    <?php 
                                        echo $this->Html->link(' ', array('controller' => 'surveys', 'action' => 'questions', $value[$sN]['id']), array('title' => "Question List", "class" => "icon-1 info-tooltip"));
                                    ?>
                                    <?php 
                                    //    echo $this->Html->link(' ', array('controller' => 'surveys', 'action' => 'delete', $value[$sN]['id']), array('onClick'=>'return confirm("Are you sure to delete this survey ?")','title' => "Delete survey", "class" => "icon-2 info-tooltip"));
                                    ?>
                                    <?php echo ($response>0)?$this->Html->link("Response ($response)", array('controller' => 'responses', 'action' => 'index', $value[$sN]['id']), array('title' => "Question List", "class" => "action")):""; ?>
                                </td>
                            </tr>
                        <?php 
                            $alt++;
                            endforeach; 
                        ?>
                        </table>
                    </div>
                    <table border="0" cellpadding="0" cellspacing="0" id="paging-table">
                    <?php if(($this->paginator->params['paging'][$sN]['pageCount']) > 1): ?>
                        <?php echo $this->element('pagination');?>       
                    <?php endif; ?>
                    </table>
                    <div class="clear"></div>
                </div>
            </td>
            <td id="tbl-border-right"></td>
	</tr>
	<tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<script type="text/javascript">
jQuery(document).ready(function(){
            jQuery("#surveyMenu").addClass('current');
});
</script>